<div class="maintop">
	当前位置：商品分类
	<a href="javascript:;" action="<?=$basepath?>_add" class="mainFrame button icon-plus">添加分类</a>
	<a href="javascript:;" action="<?=$basepath?>?<?=$this->page_url($searchdata['page_current'],$page_url)?>" class="mainFrame button">刷新</a>
</div>
<div class="main-search">
            <table width="100%">
                <tbody><tr>
                    <td>
                        <form action="<?=$basepath?>" id="brandsSearch" method="get" target="ajax" dataType="html" onajax="beforeSearchForm" call="searchForm" container="#iframe" isLoad="true">
                            <select id="categoryid" name="categoryid">
                                <option value="" selected="selected">全部分类</option>
                                <? foreach($parent_category as $v){ ?>
                                <option value="<?=$v['id']?>"><?=$v['title']?></option>
                                <? } ?>
                            </select>
                            <input type="text" id="sKey" name="sKey" class="int" placeholder="搜索关键字" value="<?=$this->existsKeyInArray('sKey',$searchdata,'S')?>" />
                            每页：
                            <select id="ps" name="ps">
                                <option value="12" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 12) echo 'selected';?> >12</option>
                                <option value="20" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 20) echo 'selected';?> >20</option>
                                <option value="30" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 30) echo 'selected';?> >30</option>
                                <option value="50" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 50) echo 'selected';?> >50</option>
                                <option value="100" <?php if($this->existsKeyInArray('ps',$searchdata,'N',$this->pagesize) == 100) echo 'selected';?> >100</option>
                            </select>
                            <input type="submit" value="搜索" class="upbutton">
                        </form>
                    </td>
                </tr>
            </tbody></table>
</div>
<div id="mainbody">
	<table width="100%" class="tablist">
	<tr class="trbg"><th colspan="2">分类名称 / 副标题</th><th>商品管理</th><th>图标</th><th>色彩设置</th><th>链接</th><th>状态</th><th>排序</th><th width="80">操作</th></tr>
	<? foreach($datas as $v){ ?>
	<tr>
	<td width="30"><i class="icon-folder-open"></i></td>
	<td class="tdleft"><strong><?=$v['title']?></strong>【<?=$v['subtitle']?>】</td>
    <td></td>
	<td><img src="<?=($v['icon']!="#" ? $v['icon'] : IMG.'nopic.png') ?>" height="16" border="16" /></td>
	<td><span class="upbutton" style="background:<?=$v['bgcolor']?>;color:<?=$v['txtcolor']?>">标题色彩</span></td>
	<td><?=$v['url']?></td>
	<td><a href="<?=$basepath?>_state?id=<?=$v['id']?>&state=<?=$v['state']?>" target="ajax" func="loadpage" class="upbutton state<?=$v['state']?>"><?=($v['state']?'正常':'禁用')?></a></td>
	<td><?=$v['sort']?></td>
	<td>
		<a action="<?=$basepath?>_delete?id=<?=$v['id']?>" title="删除" class="mainFrame button icon-trash-2" href="javascript:;"></a>
		<a action="<?=$basepath?>_edit?id=<?=$v['id']?>" title="编辑" class="mainFrame button icon-edit" href="javascript:;"></a>
	</td>
	</tr>
		<? foreach($v['subdata'] as $vsub){ ?>
		<tr>
		<td width="30" style="border-right:0px;"></td>
		<td class="tdleft"><i class="icon-right-dir"></i><?=$vsub['title']?>【<?=$vsub['subtitle']?>】</td>
        <td>
            <a action="/product/products?categoryid=<?=$v['id']?>&categorysubid=<?=$vsub['id']?>" title="管理商品" class="mainFrame button icon-th-list" href="javascript:;" style="float:inherit"></a>
            <a action="/product/products_add?categoryid=<?=$v['id']?>&categorysubid=<?=$vsub['id']?>" title="添加商品" class="mainFrame button icon-plus" href="javascript:;" style="float:inherit"></a>
        </td>
		<td><img src="<?=($vsub['icon']!="#" ? $vsub['icon'] : IMG.'nopic.png') ?>" height="16" border="16" /></td>
		<td><span class="upbutton" style="background:<?=$vsub['bgcolor']?>;color:<?=$vsub['txtcolor']?>">标题色彩</span></td>
		<td><?=$vsub['url']?></td>
		<td><a href="<?=$basepath?>_state?id=<?=$vsub['id']?>&state=<?=$vsub['state']?>" target="ajax" func="loadpage" class="upbutton state<?=$vsub['state']?>"><?=($vsub['state']?'正常':'禁用')?></a></td>
		<td><?=$vsub['sort']?></td>
		<td>
			<a action="<?=$basepath?>_delete?id=<?=$vsub['id']?>" title="删除" class="mainFrame button icon-trash-2" href="javascript:;"></a>
			<a action="<?=$basepath?>_edit?id=<?=$vsub['id']?>" title="编辑" class="mainFrame button icon-edit" href="javascript:;"></a>
		</td>
		</tr>
		<? } ?>
	<? } ?>
</div>
<script type="text/javascript">
    function beforeSearchForm(){
        var _key = this.sKey.value;
        if(_key.length<=0){
            //throw '搜索关键字不能为空';
        }
    }
    function searchForm(self, _html, data){
        $("#iframe").html(_html);
    }
    $(document).ready(function(){
        <?php
        if(!empty($searchdata['categoryid'])){
            echo '$("#categoryid option[value=\''.$searchdata['categoryid'].'\']").attr("selected", "selected");';
        }
        if(!empty($searchdata['sKey'])){
            echo '$("#sKey").val("'.$searchdata['sKey'].'");';
        }
        ?>

    });
</script>
